from flask import Blueprint, session, redirect, request, url_for

admin_blu = Blueprint("admin",__name__,url_prefix="/admin")

from . import views


@admin_blu.before_request
def check_admin():
    # 如果不是管理员，直接跳到主页,而且当前访问的ｕｒｌ不是管理员登录界面
    is_admin = session.get("is_admin",False)
    # if not is_admin:
    if not is_admin and not request.url.endswith(url_for("admin.login")):
        return redirect('/')



